package learningThread.syn.synchronizedMethodLockObj.part1;

public class OperationObj1 {

    private int num = 0;

    /**
     * 由于线程不同步,所以导致 num值会被修改
     * @param username
     */
    public synchronized void method(String username){
        try {
            System.out.println("begin method:"+Thread.currentThread().getName());
            Thread.sleep(5000);
            System.out.println("end method:"+Thread.currentThread().getName());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
